package com.dayuanit.dy17.mix.thread;

import java.util.concurrent.*;

public class ThreadPoolUtils {
    public static void main(String[] args) {
        //JDK提供的线程池工具类

        //由于工具类生成的线程池，里面的队列是无界的，容易产生内存溢出的问题，所以不建议使用。
        ExecutorService executorService = Executors.newFixedThreadPool(5);

        ExecutorService executorService1 = Executors.newSingleThreadExecutor();

        Executors.newCachedThreadPool();

        //建议使用底层的ThreadPoolExceutor来创建线程池
        new ThreadPoolExecutor(5, 5, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10));

    }
}
